package com.tao.plan.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

@Component
@Slf4j
public class RedisUtil {
    @Autowired
    private StringRedisTemplate redisTemplate;

    // 验证码
    public void setVerifyCode(String email, String code){
        String key = "vertifyCode:" + email;
        redisTemplate.opsForValue().set(key,code,120,TimeUnit.SECONDS);
    }
    public String getVerifyCode(String email){
        String key = "vertifyCode:" + email;
        return redisTemplate.opsForValue().get(key);
    }
}
